#ifndef _SERVER_H
#define _SERVER_H

#include <my_header.h>
#include "tidarr.h"

#define MAX 10

typedef enum  
{
    PWD,
    CD,
    LS,
    MKDIR,
    RMDIR,
    REMOVE,
    SENDFILE,
    RECVFILE

}CO_TYPE;

typedef enum 
{
    FILE_START,
    FILE_NEXT,
    FILE_END,
    FILE_CUT

}FILE_SESSION;


typedef struct TaskData //工人线程收到的具体任务
{
    int netfd;
    int netfd_use;
    CO_TYPE type;
    int pathlen;     //路径长度
    char path[1024]; //路径内容
    int assiglen;  
    char assig[1024]; //任务内容
    pthread_mutex_t  fd_mutex; //对目录进行增删改查需要加锁
    pthread_cond_t   fd_cond;  

}TaskData_t;

typedef struct Task
{
    TaskData_t* data; // Task数据
    struct Task* next;     //指向下个节点的指针
}Task_t;

typedef struct TaskQue
{
    int que_size;
    Task_t* front; // 任务队列头指针
    Task_t* back;  // 任务队列尾指针
}TaskQue_t;

typedef struct ThreadPool
{   TidArr_t*  tidArr;
    pthread_cond_t cond;
    pthread_mutex_t mutex;
    TaskQue_t* taskque;
    int isdead;
}ThreadPool_t;

typedef enum 
{
    FIXED,
    DYNAMIC 

}THREAD_TYPE;

ThreadPool_t* ThreadPool_init();
int ThreadPool_add();
int ThreadPool_del();
TaskQue_t* TaskQue_init();
int TaskQue_push(TaskQue_t* que,Task_t *task);
int TaskQue_pop(TaskQue_t* que);
Task_t* Task_create(TaskData_t* taskdata);
#endif 
